package com.alpaca.recommend.mapreduce;

import com.alpaca.recommend.util.SpringContextLoader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * Created by justin on 15-2-11.
 */
@Service
public class MapRedWrapper {

    public void doMapRedAsych() throws ExecutionException, InterruptedException {
        try {
            CalculateDefaultRecommend.executeJob();
            boolean isUItemRank = CalculateUItemsRank.excuteJob();
            if(isUItemRank){
                CalculateURecommend.executeJob();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }


    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        SpringContextLoader.init();
        MapRedWrapper wrapper = (MapRedWrapper) SpringContextLoader.getBean("mapRedWrapper");
        wrapper.doMapRedAsych();
    }
}

